<template>
  <el-tooltip effect="dark" :content="title" placement="top" :disabled="!!!title">
    <el-icon :size="icon.size" :color="icon.color" @click.stop="onClick" v-if="icon && typeof icon === 'object'">
      <component :is="icon.icon"></component>
    </el-icon>
    <el-icon @click.stop="onClick" v-else>
      <component :is="icon"></component>
    </el-icon>
  </el-tooltip>
</template>
<script setup lang="ts">
const props = withDefaults(
  defineProps<{
    icon: any;
    title?: string;
  }>(),
  {},
);
const emit = defineEmits<{
  //fn为父组件引入子组件是定义的子组件事件属性，可随意定义
  (event: 'onClick'): void;
}>();
const onClick = () => {
  emit('onClick');
};
</script>
<style scoped lang="scss"></style>
